//
//  CheckNetWork.m
//  Running
//
//  Created by 郑东喜 on 2016/10/30.
//  Copyright © 2016年 郑东喜. All rights reserved.
//

#import "CheckNetWork.h"

@implementation CheckNetWork

+(void)checkNetStatus {
    AFNetworkReachabilityManager *manager = [AFNetworkReachabilityManager sharedManager];
    
    [manager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status) {
        
        // 当网络状态改变时调用
        switch (status) {
            case AFNetworkReachabilityStatusUnknown:
                NSLog(@"未知网络");
                break;
            case AFNetworkReachabilityStatusNotReachable:
                NSLog(@"没有网络");
                
                [[NSNotificationCenter defaultCenter] postNotificationName:@"netStatus" object:self userInfo:@{@"name":[NSString stringWithFormat:@"%zd",status]}];
                break;
            case AFNetworkReachabilityStatusReachableViaWWAN:
                NSLog(@"手机自带网络");
                break;
            case AFNetworkReachabilityStatusReachableViaWiFi:
                NSLog(@"WIFI");
                break;
        }
    }];
    
    //开始监控
    [manager startMonitoring];
    
}

@end
